import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
import _createClass from "@babel/runtime/helpers/esm/createClass";
import _inherits from "@babel/runtime/helpers/esm/inherits";
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
import _applyDecoratedDescriptor from "@babel/runtime/helpers/esm/applyDecoratedDescriptor";
var _excluded = ["buttonEditProps"];

var _dec, _dec2, _dec3, _class;

/**
 * ButtonEditModal.js
 * @date 2018-12-12

 */
import React from 'react';
import { Modal } from 'antd';
import { Bind } from 'lodash-decorators';
import ButtonEdit from "./ButtonEdit";
var modalBodyStyle = {
  minHeight: 500,
  overflowY: 'auto'
};
var ButtonEditModal = (_dec = Bind(), _dec2 = Bind(), _dec3 = Bind(), (_class = /*#__PURE__*/function (_React$Component) {
  _inherits(ButtonEditModal, _React$Component);

  var _super = _createSuper(ButtonEditModal);

  function ButtonEditModal() {
    var _this;

    _classCallCheck(this, ButtonEditModal);

    for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
      args[_key] = arguments[_key];
    }

    _this = _super.call.apply(_super, [this].concat(args));
    _this.buttonEditRef = void 0;
    return _this;
  }

  _createClass(ButtonEditModal, [{
    key: "render",
    value: function render() {
      var _this$props = this.props,
          buttonEditProps = _this$props.buttonEditProps,
          modalProps = _objectWithoutProperties(_this$props, _excluded);

      return /*#__PURE__*/React.createElement(Modal, Object.assign({
        title: "\u6309\u94AE\u52A8\u4F5C",
        width: 800,
        bodyStyle: modalBodyStyle
      }, modalProps, {
        onOk: this.handleModalOk,
        onCancel: this.handleModalCancel,
        destroyOnClose: true
      }), /*#__PURE__*/React.createElement(ButtonEdit, Object.assign({}, buttonEditProps, {
        onRef: this.refButtonEdit
      })));
    }
  }, {
    key: "refButtonEdit",
    value: function refButtonEdit(buttonEdit) {
      this.buttonEditRef = buttonEdit;
    }
  }, {
    key: "handleModalOk",
    value: function handleModalOk() {
      var _this2 = this;

      if (this.buttonEditRef) {
        this.buttonEditRef.getValidateData().then(function (validateData) {
          var onOk = _this2.props.onOk;

          if (onOk) {
            onOk(validateData);
          }
        }).catch(function () {// 校验出错
        });
      }
    }
  }, {
    key: "handleModalCancel",
    value: function handleModalCancel() {
      var onCancel = this.props.onCancel;

      if (onCancel) {
        onCancel();
      }
    }
  }]);

  return ButtonEditModal;
}(React.Component), (_applyDecoratedDescriptor(_class.prototype, "refButtonEdit", [_dec], Object.getOwnPropertyDescriptor(_class.prototype, "refButtonEdit"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "handleModalOk", [_dec2], Object.getOwnPropertyDescriptor(_class.prototype, "handleModalOk"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "handleModalCancel", [_dec3], Object.getOwnPropertyDescriptor(_class.prototype, "handleModalCancel"), _class.prototype)), _class));
export { ButtonEditModal as default };